package masterjava.reporting.settings;

import masterjava.common.convertion.FileConverter;
import masterjava.common.settings.AppProps;
import masterjava.common.settings.PropsFactory;
import masterjava.common.settings.SettingValues;
import masterjava.common.shared.EntryMap;
import masterjava.common.store.Property;
import masterjava.reporting.shared.ReportingSettingKeys;

import java.io.File;

/**
 * User: GKislin
 * Date: 22.01.11
 * <p/>
 * Singleton
 */

public class ReportingProps implements SettingValues {

    public static Property<File> SETTINGS_FILE;
    public static Property<String> SETTINGS;
    public static Property<File> REPORTING_START_FILE;
    public static Property<String> REPORTING_START_TEMPLATE;
    public static Property<File> REPORTING_ROBOT_INSTANCE_FILE;
    public static Property<String> REPORTING_ROBOT_INSTANCE_TEMPLATE;
    public static Property<File> REPORTING_ROBOT_TYPE_FILE;
    public static Property<String> REPORTING_ROBOT_TYPE_TEMPLATE;

    public void setPropsFactory(final PropsFactory propsFactory) {
        SETTINGS_FILE = propsFactory.create(ReportingSettingKeys.settingsFile, FileConverter.get());
        SETTINGS = propsFactory.createFieStore(ReportingSettingKeys.settings, SETTINGS_FILE);
        REPORTING_START_FILE = propsFactory.create(ReportingSettingKeys.reportingStartFile, FileConverter.get());
        REPORTING_START_TEMPLATE = propsFactory.createFieStore(ReportingSettingKeys.reportingStartTemplate, REPORTING_START_FILE);
        REPORTING_ROBOT_INSTANCE_FILE = propsFactory.create(ReportingSettingKeys.reportingRobotInstanceFile, FileConverter.get());
        REPORTING_ROBOT_INSTANCE_TEMPLATE = propsFactory.createFieStore(ReportingSettingKeys.reportingRobotInstanceTemplate, REPORTING_ROBOT_INSTANCE_FILE);
        REPORTING_ROBOT_TYPE_FILE = propsFactory.create(ReportingSettingKeys.reportingRobotTypeFile, FileConverter.get());
        REPORTING_ROBOT_TYPE_TEMPLATE = propsFactory.createFieStore(ReportingSettingKeys.reportingRobotTypeTemplate, REPORTING_ROBOT_TYPE_FILE);
    }

    @Override
    public EntryMap getSettingValues() {
        EntryMap map = AppProps.createSettingValues();
        map.addProp(SETTINGS_FILE, SETTINGS,
                REPORTING_START_FILE, REPORTING_START_TEMPLATE,
                REPORTING_ROBOT_INSTANCE_FILE, REPORTING_ROBOT_INSTANCE_TEMPLATE,
                REPORTING_ROBOT_TYPE_FILE, REPORTING_ROBOT_TYPE_TEMPLATE);
        return map;
    }
}
